'use strict';

module.exports = app => {
  const { router, controller: { user }, middleware: { validator, checkPageTable, checkParams } } = app;

  const baseUrl = '/api/user';
  router.post(baseUrl + '/checkToken', user.checkToken);
  router.post(baseUrl + '/login', validator('user.login'), user.login);
  router.post(baseUrl + '/logout', user.logout);
  router.get(baseUrl + '/statisticalUser', user.statisticalUser);
  router.get(baseUrl, checkPageTable(), user.index);
  router.get(baseUrl + '/:id', checkParams(), user.show);
  router.post(baseUrl, validator('user.create'), user.create);
  router.put(baseUrl + '/:id', checkParams(), validator('user.update'), user.update);
};
